import requests

from common.baseApi import BaseAPI

class LoginAPI(BaseAPI):
    def login(self,username,password,getCookies=True):
        """

        :param username: 用户名
        :param password: 密码
        :param getCookies:  区分给业务类用还是自己用
        调用通用的request_send
        :return:  cookies或json
        """
        payload = {"user":{"email":username},"password": password,"code":"","locale":"zh-cn"}
        if getCookies:
            return self.request_send(method='post',json=payload).cookies
        else:
            return self.request_send(method='post', json=payload).json()

if __name__ == '__main__':
    cookies = LoginAPI().login('1184882444@qq.com','123456a')
    payload = {"utcOffset":8}
    print(requests.post(url='http://124.223.33.41:7070/api/v4/users/validate', json=payload, cookies=cookies).json())

